package com.example.demo99.Service.Impl;

import com.example.demo99.Entity.AccountRecord;
import com.example.demo99.Mapper.AccountRecordMapper; // 注意：不是 Repository！
import com.example.demo99.Service.AccountRecordService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountRecordServiceImpl implements AccountRecordService {

    private final AccountRecordMapper mapper;

    public AccountRecordServiceImpl(AccountRecordMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public AccountRecord save(AccountRecord record) {
        mapper.insertRecord(record);
        return record; // 插入成功后返回原始对象，或查询数据库返回新对象
    }

    @Override
    public List<AccountRecord> getAllRecords() {
        return mapper.selectAllRecords();
    }
}
